package atlas2excel
{
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;

	import iris.define.Char;
	import iris.define.CharSet;
	import iris.utils.IrisStringUtil;

	public class AAtlasReader
	{
		protected var _luaFile:File

		public function AAtlasReader(luaFile:File)
		{
			_luaFile = luaFile;
		}

		public function parseLua():void
		{
			var fs:FileStream = new FileStream();
			fs.open(_luaFile, FileMode.READ);

			var luaText:String = fs.readMultiByte(fs.bytesAvailable, CharSet.UTF_8);
			var luaTexts:Array = _luaText.split(File.lineEnding);

			var indices:Array = IrisStringUtil.intercept(luaText,
				"-- Index" + File.lineEnding, File.lineEnding + File.lineEnding, false, false).split(File.lineEnding);

			var lootDatas:Array = IrisStringUtil.interceptAll(luaText,
				"AtlasLoot_Data", Char.CHAR_CODE_9 + "};", true, true);

			for each(var lootData:String in lootDatas)
			{
				var dataIndex:String = IrisStringUtil.intercept(lootData,
					"AtlasLoot_Data[\"", "\"]", false, false);
				
			}
		}
	}
}